import { http } from '@/server'

/** 获取培训计划详情数据 */
export const fetchTrainPlanDetail = async (id: number) => {
    try {
        const { data } = await http.get(`/engineer/plan/info/${id}`)
        return data
    } catch (error) {
        return undefined
    }
}

/**
 * 培训计划审核 - 通过
 * @param {number} 培训计划id
 */
export const approveTrainPlan = async (id: number) => {
    return await http.post(`/engineer/plan/check/${id}`, {
        check: 1,
    })
}

/**
 * 培训计划审核 - 驳回
 * @param {number} 培训计划id
 * @param {reason} 意见
 */
export const rejectTrainPlan = async (id: number, reason: string) => {
    return await http.post(`/engineer/plan/check/${id}`, {
        check: 2,
        check_reason: reason,
    })
}
